package com.jsyh.maidu.presenter;

import android.content.Context;

import com.jsyh.maidu.config.ConfigValue;
import com.jsyh.maidu.http.BaseDelegate;
import com.jsyh.maidu.http.ExceptionHelper;
import com.jsyh.maidu.http.OkHttpClientManager;
import com.jsyh.maidu.model.BaseModel;
import com.jsyh.maidu.utils.Utils;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by ZHY_9 on 2017/6/15.
 */

public class DeleteScanOrderPresenter extends BasePresenter {

    public DeleteScanOrderPresenter() {
    }

    public void deleteScanOrder(final Context context, int id){
        initLoadDialog(context);
        mLoadingDialog.show();
        Map<String, String> params = new HashMap<>();
        params.put("key", ConfigValue.DATA_KEY);
        params.put("order_id", String.valueOf(id));
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "scan/delOrder",
                params, new BaseDelegate.ResultCallback<BaseModel>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        mLoadingDialog.dismiss();
                        Utils.showToast(context, ExceptionHelper.getMessage(e, context));
                    }

                    @Override
                    public void onResponse(BaseModel response, Object tag) {
                        mLoadingDialog.dismiss();
                        Utils.showToast(context, "取消成功！");
                    }
                }, true);


    }
}
